var a = require("../../utils/config.js");

Page({
    data: {
        list: [],
        page: 1,
        isEnd: !1,
        keyWords: ""
    },
    onLoad: function(a) {
        this.loadDataSource();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.page = 1, this.loadDataSource();
    },
    onReachBottom: function() {
        this.data.isEnd || (this.data.page++, this.loadDataSource());
    },
    onShareAppMessage: function() {},
    loadDataSource: function() {
        var t = this;
        1 == this.data.page && (t.setData({
            isEnd: !1
        }), t.data.list = []), wx.request({
            url: a.urlList.API_ISSUE_SEARCH,
            data: {
                page: t.data.page,
                rows: 10,
                keyWords: t.data.keyWords,
                serviceProviderId: wx.getStorageSync("serviceProviderId")
            },
            success: function(a) {
                t.setData({
                    list: t.data.list.concat(a.data.data)
                }), a.data.data.length < 10 && (t.data.page--, t.setData({
                    isEnd: !0
                })), wx.stopPullDownRefresh();
            }
        });
    },
    goToDetail: function(a) {
        var t = this, e = a.currentTarget.dataset.index, o = t.data.list[e].id, i = t.data.list[e].title;
        wx.navigateTo({
            url: "/pages/web/web?src=https://www.xiangyaowant.com/web/detail/" + o + "&title=" + i
        });
    },
    getKeyWords: function(a) {
        this.setData({
            keyWords: a.detail.value
        });
    },
    search: function() {
        this.onPullDownRefresh();
    }
});